From bffbaddb797e0229e6d9e30fe0f75d56b4530903 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Mon, 17 Oct 2022 02:52:41 -0400 Subject: general: Add missing pragma once --- src/common/fixed_point.h | 5 +---- src/core/hle/service/vi/vi_results.h | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/fixed_point.h b/src/common/fixed_point.h index 4a0f72cc9..f9adfccb0 100644 --- a/src/common/fixed_point.h +++ b/src/common/fixed_point.h @@ -4,8 +4,7 @@ // From: https://github.com/eteran/cpp-utilities/blob/master/fixed/include/cpp-utilities/fixed.h // See also: http://stackoverflow.com/questions/79677/whats-the-best-way-to-do-fixed-point-math -#ifndef FIXED_H_ -#define FIXED_H_ +#pragma once #if __cplusplus >= 201402L #define CONSTEXPR14 constexpr @@ -702,5 +701,3 @@ constexpr bool operator!=(Number lhs, FixedPoint rhs) { } // namespace Common #undef CONSTEXPR14 - -#endif diff --git a/src/core/hle/service/vi/vi_results.h b/src/core/hle/service/vi/vi_results.h index a46c247d2..22bac799f 100644 --- a/src/core/hle/service/vi/vi_results.h +++ b/src/core/hle/service/vi/vi_results.h @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + #include "core/hle/result.h" namespace Service::VI { -- cgit v1.2.3 From 88ccdaf10af1a055854c7b094882a3ed7af37e4b Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Mon, 17 Oct 2022 03:16:54 -0400 Subject: fixed_point: Replace CONSTEXPR14 with constexpr As we require the latest C++ standards to compile yuzu, checking for C++14 constexpr is not needed. --- src/common/fixed_point.h | 92 ++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/src/common/fixed_point.h b/src/common/fixed_point.h index f9adfccb0..6eb6afe2f 100644 --- a/src/common/fixed_point.h +++ b/src/common/fixed_point.h @@ -6,12 +6,6 @@ #pragma once -#if __cplusplus >= 201402L -#define CONSTEXPR14 constexpr -#else -#define CONSTEXPR14 -#endif - #include // for size_t #include #include @@ -105,7 +99,7 @@ constexpr B next_to_base(N rhs) { struct divide_by_zero : std::exception {}; template -CONSTEXPR14 FixedPoint divide( +constexpr FixedPoint divide( FixedPoint numerator, FixedPoint denominator, FixedPoint& remainder, typename std::enable_if::next_size::is_specialized>::type* = nullptr) { @@ -125,7 +119,7 @@ CONSTEXPR14 FixedPoint divide( } template -CONSTEXPR14 FixedPoint divide( +constexpr FixedPoint divide( FixedPoint numerator, FixedPoint denominator, FixedPoint& remainder, typename std::enable_if::next_size::is_specialized>::type* = nullptr) { @@ -195,7 +189,7 @@ CONSTEXPR14 FixedPoint divide( // this is the usual implementation of multiplication template -CONSTEXPR14 FixedPoint multiply( +constexpr FixedPoint multiply( FixedPoint lhs, FixedPoint rhs, typename std::enable_if::next_size::is_specialized>::type* = nullptr) { @@ -214,7 +208,7 @@ CONSTEXPR14 FixedPoint multiply( // it is slightly slower, but is more robust since it doesn't // require and upgraded type template -CONSTEXPR14 FixedPoint multiply( +constexpr FixedPoint multiply( FixedPoint lhs, FixedPoint rhs, typename std::enable_if::next_size::is_specialized>::type* = nullptr) { @@ -283,7 +277,7 @@ public: // constructors public: // conversion template - CONSTEXPR14 explicit FixedPoint(FixedPoint other) { + constexpr explicit FixedPoint(FixedPoint other) { static_assert(I2 <= I && F2 <= F, "Scaling conversion can only upgrade types"); using T = FixedPoint; @@ -352,81 +346,81 @@ public: // unary operators return FixedPoint::from_base(+data_); } - CONSTEXPR14 FixedPoint& operator++() { + constexpr FixedPoint& operator++() { data_ += one; return *this; } - CONSTEXPR14 FixedPoint& operator--() { + constexpr FixedPoint& operator--() { data_ -= one; return *this; } - CONSTEXPR14 FixedPoint operator++(int) { + constexpr FixedPoint operator++(int) { FixedPoint tmp(*this); data_ += one; return tmp; } - CONSTEXPR14 FixedPoint operator--(int) { + constexpr FixedPoint operator--(int) { FixedPoint tmp(*this); data_ -= one; return tmp; } public: // basic math operators - CONSTEXPR14 FixedPoint& operator+=(FixedPoint n) { + constexpr FixedPoint& operator+=(FixedPoint n) { data_ += n.data_; return *this; } - CONSTEXPR14 FixedPoint& operator-=(FixedPoint n) { + constexpr FixedPoint& operator-=(FixedPoint n) { data_ -= n.data_; return *this; } - CONSTEXPR14 FixedPoint& operator*=(FixedPoint n) { + constexpr FixedPoint& operator*=(FixedPoint n) { return assign(detail::multiply(*this, n)); } - CONSTEXPR14 FixedPoint& operator/=(FixedPoint n) { + constexpr FixedPoint& operator/=(FixedPoint n) { FixedPoint temp; return assign(detail::divide(*this, n, temp)); } private: - CONSTEXPR14 FixedPoint& assign(FixedPoint rhs) { + constexpr FixedPoint& assign(FixedPoint rhs) { data_ = rhs.data_; return *this; } public: // binary math operators, effects underlying bit pattern since these // don't really typically make sense for non-integer values - CONSTEXPR14 FixedPoint& operator&=(FixedPoint n) { + constexpr FixedPoint& operator&=(FixedPoint n) { data_ &= n.data_; return *this; } - CONSTEXPR14 FixedPoint& operator|=(FixedPoint n) { + constexpr FixedPoint& operator|=(FixedPoint n) { data_ |= n.data_; return *this; } - CONSTEXPR14 FixedPoint& operator^=(FixedPoint n) { + constexpr FixedPoint& operator^=(FixedPoint n) { data_ ^= n.data_; return *this; } template ::value>::type> - CONSTEXPR14 FixedPoint& operator>>=(Integer n) { + constexpr FixedPoint& operator>>=(Integer n) { data_ >>= n; return *this; } template ::value>::type> - CONSTEXPR14 FixedPoint& operator<<=(Integer n) { + constexpr FixedPoint& operator<<=(Integer n) { data_ <<= n; return *this; } @@ -484,7 +478,7 @@ public: // conversion to basic types } public: - CONSTEXPR14 void swap(FixedPoint& rhs) { + constexpr void swap(FixedPoint& rhs) { using std::swap; swap(data_, rhs.data_); } @@ -496,8 +490,8 @@ public: // if we have the same fractional portion, but differing integer portions, we trivially upgrade the // smaller type template -CONSTEXPR14 typename std::conditional= I2, FixedPoint, FixedPoint>::type -operator+(FixedPoint lhs, FixedPoint rhs) { +constexpr typename std::conditional= I2, FixedPoint, FixedPoint>::type operator+( + FixedPoint lhs, FixedPoint rhs) { using T = typename std::conditional= I2, FixedPoint, FixedPoint>::type; @@ -507,8 +501,8 @@ operator+(FixedPoint lhs, FixedPoint rhs) { } template -CONSTEXPR14 typename std::conditional= I2, FixedPoint, FixedPoint>::type -operator-(FixedPoint lhs, FixedPoint rhs) { +constexpr typename std::conditional= I2, FixedPoint, FixedPoint>::type operator-( + FixedPoint lhs, FixedPoint rhs) { using T = typename std::conditional= I2, FixedPoint, FixedPoint>::type; @@ -518,8 +512,8 @@ operator-(FixedPoint lhs, FixedPoint rhs) { } template -CONSTEXPR14 typename std::conditional= I2, FixedPoint, FixedPoint>::type -operator*(FixedPoint lhs, FixedPoint rhs) { +constexpr typename std::conditional= I2, FixedPoint, FixedPoint>::type operator*( + FixedPoint lhs, FixedPoint rhs) { using T = typename std::conditional= I2, FixedPoint, FixedPoint>::type; @@ -529,8 +523,8 @@ operator*(FixedPoint lhs, FixedPoint rhs) { } template -CONSTEXPR14 typename std::conditional= I2, FixedPoint, FixedPoint>::type -operator/(FixedPoint lhs, FixedPoint rhs) { +constexpr typename std::conditional= I2, FixedPoint, FixedPoint>::type operator/( + FixedPoint lhs, FixedPoint rhs) { using T = typename std::conditional= I2, FixedPoint, FixedPoint>::type; @@ -547,75 +541,75 @@ std::ostream& operator<<(std::ostream& os, FixedPoint f) { // basic math operators template -CONSTEXPR14 FixedPoint operator+(FixedPoint lhs, FixedPoint rhs) { +constexpr FixedPoint operator+(FixedPoint lhs, FixedPoint rhs) { lhs += rhs; return lhs; } template -CONSTEXPR14 FixedPoint operator-(FixedPoint lhs, FixedPoint rhs) { +constexpr FixedPoint operator-(FixedPoint lhs, FixedPoint rhs) { lhs -= rhs; return lhs; } template -CONSTEXPR14 FixedPoint operator*(FixedPoint lhs, FixedPoint rhs) { +constexpr FixedPoint operator*(FixedPoint lhs, FixedPoint rhs) { lhs *= rhs; return lhs; } template -CONSTEXPR14 FixedPoint operator/(FixedPoint lhs, FixedPoint rhs) { +constexpr FixedPoint operator/(FixedPoint lhs, FixedPoint rhs) { lhs /= rhs; return lhs; } template ::value>::type> -CONSTEXPR14 FixedPoint operator+(FixedPoint lhs, Number rhs) { +constexpr FixedPoint operator+(FixedPoint lhs, Number rhs) { lhs += FixedPoint(rhs); return lhs; } template ::value>::type> -CONSTEXPR14 FixedPoint operator-(FixedPoint lhs, Number rhs) { +constexpr FixedPoint operator-(FixedPoint lhs, Number rhs) { lhs -= FixedPoint(rhs); return lhs; } template ::value>::type> -CONSTEXPR14 FixedPoint operator*(FixedPoint lhs, Number rhs) { +constexpr FixedPoint operator*(FixedPoint lhs, Number rhs) { lhs *= FixedPoint(rhs); return lhs; } template ::value>::type> -CONSTEXPR14 FixedPoint operator/(FixedPoint lhs, Number rhs) { +constexpr FixedPoint operator/(FixedPoint lhs, Number rhs) { lhs /= FixedPoint(rhs); return lhs; } template ::value>::type> -CONSTEXPR14 FixedPoint operator+(Number lhs, FixedPoint rhs) { +constexpr FixedPoint operator+(Number lhs, FixedPoint rhs) { FixedPoint tmp(lhs); tmp += rhs; return tmp; } template ::value>::type> -CONSTEXPR14 FixedPoint operator-(Number lhs, FixedPoint rhs) { +constexpr FixedPoint operator-(Number lhs, FixedPoint rhs) { FixedPoint tmp(lhs); tmp -= rhs; return tmp; } template ::value>::type> -CONSTEXPR14 FixedPoint operator*(Number lhs, FixedPoint rhs) { +constexpr FixedPoint operator*(Number lhs, FixedPoint rhs) { FixedPoint tmp(lhs); tmp *= rhs; return tmp; } template ::value>::type> -CONSTEXPR14 FixedPoint operator/(Number lhs, FixedPoint rhs) { +constexpr FixedPoint operator/(Number lhs, FixedPoint rhs) { FixedPoint tmp(lhs); tmp /= rhs; return tmp; @@ -624,13 +618,13 @@ CONSTEXPR14 FixedPoint operator/(Number lhs, FixedPoint rhs) { // shift operators template ::value>::type> -CONSTEXPR14 FixedPoint operator<<(FixedPoint lhs, Integer rhs) { +constexpr FixedPoint operator<<(FixedPoint lhs, Integer rhs) { lhs <<= rhs; return lhs; } template ::value>::type> -CONSTEXPR14 FixedPoint operator>>(FixedPoint lhs, Integer rhs) { +constexpr FixedPoint operator>>(FixedPoint lhs, Integer rhs) { lhs >>= rhs; return lhs; } @@ -699,5 +693,3 @@ constexpr bool operator!=(Number lhs, FixedPoint rhs) { } } // namespace Common - -#undef CONSTEXPR14 -- cgit v1.2.3